<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta name="description" content="">
    <link rel="stylesheet" href="css/bootstrap.min.css"/>
</head>
<body ng-app="validationApp" ng-controller="mainController">
<div class="container">
    <div class="col-sm-8 col-sm-offset-2">

        <!-- PAGE HEADER -->
        <div class="page-header"><h1>AngularJS Form Validation</h1></div>

        <!-- FORM -->
        <!-- pass in the variable if our form is valid or invalid -->
        <form name="userForm" ng-submit="submitForm(userForm.$valid)" novalidate> <!-- novalidate prevents HTML5 validation since we will be validating ourselves -->

            <!-- NAME -->
            <div class="form-group" ng-class="{ 'has-error' : userForm.name.$invalid && !userForm.name.$pristine }">
                <label>Name</label>
                <input type="text" name="name" class="form-control" ng-model="user.name" required>
                <p ng-show="userForm.name.$invalid && !userForm.name.$pristine" class="help-block">You name is required.</p>
            </div>

            <!-- USERNAME -->
            <div class="form-group" ng-class="{ 'has-error' : userForm.username.$invalid && !userForm.username.$pristine }">
                <label>Username</label>
                <input type="text" name="username" class="form-control" ng-model="user.username" ng-minlength="3" ng-maxlength="8">
                <p ng-show="userForm.username.$error.minlength" class="help-block">Username is too short.</p>
                <p ng-show="userForm.username.$error.maxlength" class="help-block">Username is too long.</p>
            </div>

            <!-- EMAIL -->
            <div class="form-group" ng-class="{ 'has-error' : userForm.email.$invalid && !userForm.email.$pristine }">
                <label>Email</label>
                <input type="email" name="email" class="form-control" ng-model="user.email">
                <p ng-show="userForm.email.$invalid && !userForm.email.$pristine" class="help-block">Enter a valid email.</p>
            </div>

            <!-- SUBMIT BUTTON -->
            <button type="submit" class="btn btn-primary" ng-disabled="userForm.$invalid">Submit</button>

        </form>

    </div><!-- col-sm-8 -->
</div><!-- /container -->
</body>
<script src="js/angular.min.js"></script>
<script src="js/form.js"></script>
</html>